package com.igeekhome.wzgl.mapper;

import com.igeekhome.wzgl.entity.AdministratorEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IAdministratorMapper {
    @Insert("insert into administrator(account,pwd) values (#{account},#{pwd})")
    int regist(AdministratorEntity re);

    @Select("select count(*) from administrator where account=#{account}")
    int isCanUse(String account);

    @Select("select * from administrator where account=#{account} and pwd=#{pwd}")
    AdministratorEntity login(AdministratorEntity ad);

    @Insert("insert into administrator(account,pwd,avatar,nick_name,real_name,phone,work_no) values (#{account},#{pwd},#{avatar}, #{nickName},#{realName},#{phone},#{workNo})")
    int addAdministrator(AdministratorEntity admin);

    @Delete("delete  from administrator where id=#{id}")
    int delete(int id);

    @Update("update administrator set account=#{account},pwd=#{pwd},nick_name=#{nickName},avatar=#{avatar},real_name=#{realName},phone=#{phone},work_no=#{workNo} where id=#{id}")
    int updata(AdministratorEntity ad);

    @Select("select * from administrator where id=#{id}")
    List<AdministratorEntity> search(int id);

    @Select("select * from administrator")
    List<AdministratorEntity> page();

    @Select("select * from administrator where id=#{id}")
    AdministratorEntity getById(int id);
}
